<!DOCTYPE html>

<html lang="en" data-content_root="../../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>Overview &#8212; Pytch  documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
    <link rel="stylesheet" type="text/css" href="../../_static/classic.css?v=36340f97" />
    <link rel="stylesheet" type="text/css" href="../../_static/css/pytch-classic.css?v=0321735e" />
    
    <script src="../../_static/documentation_options.js?v=7f41d439"></script>
    <script src="../../_static/doctools.js?v=9bcbadda"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <link rel="icon" href="../../_static/favicon.ico"/>
    <link rel="author" title="About these documents" href="../../about.html" />
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Integration with client" href="integration-with-client.html" />
    <link rel="prev" title="Pytch VM (developer guide)" href="index.html" /> 
  </head><body>
<div class="NavBar">
  <a href="../../../app/"><h1>Pytch</h1></a>
  <ul>
    <a href="https://pytch.scss.tcd.ie/"><li>About Pytch</li></a>
    <a href="../../index.html"><li>Help</li></a>
    <a href="../../../app/tutorials/"><li>Tutorials</li></a>
    <a href="../../../app/my-projects/"><li>My projects</li></a>
  </ul>
</div>
<div class="warning-work-in-progress">
  <p>These help pages are incomplete — we are working on it!</p>
</div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="overview">
<h1>Overview<a class="headerlink" href="#overview" title="Link to this heading">¶</a></h1>
<ul class="simple">
<li><p>Skulpt provides the bridge between Python and JavaScript. A “Python
object” exists as a particular kind of JavaScript object.</p></li>
<li><p>One running instance of a Pytch program is represented by a
<code class="docutils literal notranslate"><span class="pre">Project</span></code>; in the web-app, there is only one ‘live’ <code class="docutils literal notranslate"><span class="pre">Project</span></code> at
a time.</p></li>
<li><p>A Scratch-like Sprite is represented by a user-written Python class
derived from a Pytch-supplied base class; instances of the user’s
classes represent the interacting elements of a <code class="docutils literal notranslate"><span class="pre">Project</span></code>.</p></li>
<li><p>A JavaScript-side <code class="docutils literal notranslate"><span class="pre">Project</span></code> has a collection of <code class="docutils literal notranslate"><span class="pre">PytchActor</span></code>
objects, each representing such a Python class which has been
registered with the <code class="docutils literal notranslate"><span class="pre">Project</span></code>.</p></li>
<li><p>Every <code class="docutils literal notranslate"><span class="pre">PytchActor</span></code> has at least one <code class="docutils literal notranslate"><span class="pre">PytchActorInstance</span></code>, each
corresponding to a Python instance of the corresponding class;
instances can be created and registered with the <code class="docutils literal notranslate"><span class="pre">Project</span></code>; all but
the original instance can be de-registered from the <code class="docutils literal notranslate"><span class="pre">Project</span></code>.</p></li>
<li><p>Program execution happens via the <code class="docutils literal notranslate"><span class="pre">Project</span></code> maintaining a
collection of <code class="docutils literal notranslate"><span class="pre">Thread</span></code>s, organised into <code class="docutils literal notranslate"><span class="pre">ThreadGroup</span></code>s; each
<code class="docutils literal notranslate"><span class="pre">Thread</span></code> is ‘running on’ some <code class="docutils literal notranslate"><span class="pre">PytchActorInstance</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ThreadGroup</span></code>s are launched in response to events; <code class="docutils literal notranslate"><span class="pre">Thread</span></code>s
are created to run <code class="docutils literal notranslate"><span class="pre">Handler</span></code>s; the user declares <code class="docutils literal notranslate"><span class="pre">Handler</span></code>s
using Python decorator syntax.</p></li>
<li><p>Some events apply to all instances of an actor; some just to a
particular instance. Some are exogenous; some endogenous.</p></li>
<li><p>Invoking a <code class="docutils literal notranslate"><span class="pre">Handler</span></code> consists of making a call to some Python
method of some <code class="docutils literal notranslate"><span class="pre">Sprite</span></code>- or <code class="docutils literal notranslate"><span class="pre">Stage</span></code>-derived class, bound to some
instance of that class.</p></li>
<li><p>A <code class="docutils literal notranslate"><span class="pre">Thread</span></code> can be ‘running’; or it can be ‘waiting’/’sleeping’
until some ‘wake’ condition holds; or it can have terminated.</p></li>
<li><p>Pytch system calls provide services requiring support from the Pytch
runtime, such as the broadcast mechanism, which can launch new
thread-groups.</p></li>
<li><p>Multi-threading is (sometimes implicitly) cooperative; execution
proceeds in ‘frames’ (using that term as in animation); every frame,
each running thread executes until it either finishes or cedes
control back to the Pytch runtime.</p></li>
<li><p>When a thread cedes control, its continuation is captured as Skulpt
suspension.</p></li>
<li><p>To achieve some implicit cooperation, ‘cede control’ calls are
inserted by the Skulpt/Pytch compiler in ‘for’ and ‘while’ loops. Most
system calls also implicitly cede control.</p></li>
<li><p>Cross-actor communication is done by broadcasting and receiving
string messages.</p></li>
<li><p>All the above is decoupled from the browser, to allow easier testing;
the handful of dependencies are configured as mocks; testing is then
done in JavaScript (using node) on the behaviour of small Pytch
programs.</p></li>
<li><p>For Scratch-like interactive use, there is a web-app which configures
the Pytch dependencies to interact with the browser; it allows the
user to enter code, save/load their work, or load Pytch-supplied
examples.</p></li>
<li><p>The web-app runs threads and renders the current state of the live
<code class="docutils literal notranslate"><span class="pre">Project</span></code> at a nominal 60fps; each <code class="docutils literal notranslate"><span class="pre">Actor</span></code> instance has an
‘appearance’, location, and size, and can be hidden or shown. The
web-app supports sound, and approximate click- and
collision-detection.</p></li>
</ul>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper"><ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../webapp/user/index.html">Using the Pytch web app</a></li>
<li class="toctree-l1"><a class="reference internal" href="../user/index.html">Writing Pytch programs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../about.html">About Pytch</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contact.html">Contact</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../developer.html">Developer documentation</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../developer/development-setup.html">Development setup</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../developer/design-overview.html">Design overview</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="index.html">VM</a><ul class="current">
<li class="toctree-l3 current"><a class="current reference internal" href="#">Overview</a></li>
<li class="toctree-l3"><a class="reference internal" href="integration-with-client.html">Integration with client</a></li>
<li class="toctree-l3"><a class="reference internal" href="based-on-skulpt.html">Skulpt: Python / JavaScript bridge</a></li>
<li class="toctree-l3"><a class="reference internal" href="project.html">Project</a></li>
<li class="toctree-l3"><a class="reference internal" href="actor.html">Actor: Sprite and Stage</a></li>
<li class="toctree-l3"><a class="reference internal" href="actor-registration.html">Actor-class registration</a></li>
<li class="toctree-l3"><a class="reference internal" href="threading-model.html">Threading model</a></li>
<li class="toctree-l3"><a class="reference internal" href="hat-blocks.html">Hat blocks</a></li>
<li class="toctree-l3"><a class="reference internal" href="syscalls.html">Syscalls</a></li>
<li class="toctree-l3"><a class="reference internal" href="skulpt-pytch-environment.html">Skulpt API / Pytch environment</a></li>
<li class="toctree-l3"><a class="reference internal" href="testing.html">Testing</a></li>
<li class="toctree-l3"><a class="reference internal" href="ide-web-app.html">Web-app</a></li>
<li class="toctree-l3"><a class="reference internal" href="rendering.html">Rendering</a></li>
<li class="toctree-l3"><a class="reference internal" href="hit-detection.html">Collision and click detection</a></li>
<li class="toctree-l3"><a class="reference internal" href="clones.html">Clones</a></li>
<li class="toctree-l3"><a class="reference internal" href="sounds.html">Sounds</a></li>
<li class="toctree-l3"><a class="reference internal" href="tutorials.html">Tutorials</a></li>
<li class="toctree-l3"><a class="reference internal" href="docstrings.html">Docstrings</a></li>
<li class="toctree-l3"><a class="reference internal" href="attribute-watchers.html">Watching object attributes</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../webapp/developer/index.html">Webapp</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../medialib/developer/index.html">Media library</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../developer/index.html">Website</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../build-tools/index.html">Tools</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../source-build.html">Source and build information</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../releases/changelog.html">Changelog</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../legal/index.html">Legal information</a></li>
</ul>
<div class="docs-home-link"><hr>
  <ul>
    <li>
      <a href="../../index.html">Pytch help home</a>
    <li>
  </ul>
</div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
  </body>
</html>